<?php //pack11class

class ObjectsListHeaderPrice extends Module {

    public $property;
    public $label;
    public $arrow="";
    public $traceEnabled=true;

	public function setup() {
        $this->label=PropertiesManager::getProperty("price")->label;
    }

    public function draw() {
        $setting=SettingsManager::getSetting("sortby");
        $current=clone $setting;
        $current->value=$this->property->id;

        if($descSetting=SettingsManager::getSetting("desc")) {
            $desc=clone $descSetting;
            if($desc->value==1){
                $desc->value=0;
            } else {
                $desc->value=1;
            }
        }
        $queryObject=GetQuery::useDefinedVars();
        //trace("ListHeaderPrice: ".GetQuery::$qline);
        $queryObject->setValue($current,GetQueryObject::SETTING);
        $queryObject->setValue($desc,GetQueryObject::SETTING);

        $query=GetQuery::generate($queryObject);
        $link="?state=".$query;
        //$link='Javascript:ObjectsManager.useObjects("'.$query.'");';
        if(array_key_exists("search", $_GET)) $link='Javascript:PostData.release("'.$query.'&search");';
        $this->setBody("<a href='{$link}'>{$this->label}</a>");
        if($setting->value==$this->property->id){
            $arrow=new ObjectsListHeaderSortArrow;
            $arrowImage=($descSetting->value==1)? "up":"down";
            $arrow->setBody($arrowImage);
            $this->arrow=Template::html($arrow);
        }
        //GetQuery::translate($query);
    }

}
?>
